#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    int countTime(string time)
    {
        int counthour = 0, countminute = 0;
        for (int i = 0; i < 24; ++i)
        {
            int high = i / 10;
            int low = i % 10;
            if ((time[0] == '?' or time[0] == (high + '0')) and
                (time[1] == '?' or time[1] == (low + '0')))
            {
                counthour++;
            }
        }
        for (int i = 0; i < 60; ++i)
        {
            int high = i / 10;
            int low = i % 10;
            if ((time[3] == '?' or time[3] == (high + '0')) and
                (time[4] == '?' or time[4] == (low + '0')))
            {
                countminute++;
            }
        }
        return counthour * countminute;
    }
};